package yunhe.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import yunhe.biz.ReceiptBiz;
import yunhe.entity.ReceiptFlow;
@WebServlet(name="checkPreServlet",urlPatterns="/checkPreServlet")
public class checkPreServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			ReceiptBiz receiptbiz = new ReceiptBiz();
			List<ReceiptFlow> rec =receiptbiz.searchRec();
			HttpSession session = request.getSession();
			
			if(rec!=null){
				
				session.setAttribute("rec", rec);
				request.getRequestDispatcher("receipt/checkPre.jsp").forward(request, response);
			}else{
				
				response.sendRedirect("index.jsp");
			}
	}
	
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
	}
}
